package cn.tedu.thread;

public class SyncDemo3 {
    public static void main(String[] args) {
        Thread t1 = new Thread(){
            public void run(){
                Boo.dosome();
            }
        };
        Thread t2 = new Thread(() -> {
            Boo.dosome();
        });
        t1.start();
        t2.start();
    }
}
class Boo{
    public  static void dosome(){
        synchronized (Boo.class){
            Thread t = Thread.currentThread();
            System.out.println(t.getName()+"正在执行dosome方法");
            try {
                Thread.sleep(5000);
                System.out.println(t.getName()+"执行完毕");
            } catch (InterruptedException e) {
                System.out.println("阻塞5秒异常");
            }
        }

    }
}